# -*- coding: utf-8 -*-
# @Author : HaleShi
# @Time : 2023-07-03
# @File : 19_hook_pageToken.py

import frida
import sys

rdev = frida.get_remote_device()
session = rdev.attach("唯品会")

scr = """
Java.perform(function () {

    var o = Java.use("qb.o");
    o.o1.implementation = function(i10, str, dVar){
        console.log("——————————————————————o1请求来了——————————————————————");
        // console.log("i10",i10);
        console.log("这是o1中的参数str:",str);
        // console.log("dVar",dVar);
        var res = this.o1(i10, str, dVar)
        // console.log("这是res：",res);
        // console.log(Java.use("android.util.Log").getStackTraceString(Java.use("java.lang.Throwable").$new()));
        return res;
    };
    
    var b = Java.use("q4.b");
        b.onConnection.implementation = function(i10, objArr){
        console.log("——————————————————————onConnection请求来了——————————————————————");
        //console.log("i10",i10);
        //console.log("objArr",objArr);
        var res = this.onConnection(i10, objArr)
        console.log("这是res：",res);
        //console.log(Java.use("android.util.Log").getStackTraceString(Java.use("java.lang.Throwable").$new()));
        return res;
    };
    
});
"""

script = session.create_script(scr)


def on_message(message, data):
    print(message, data)


script.on("message", on_message)

script.load()
sys.stdin.read()
